home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / utility / freedos.zip / COM050.ZIP / LOADHIGH.H < prev    next >
C/C++ Source or Header  |  1996-01-17  |  4KB  |  113 lines

  1. /* LOADHIGH.H - contains macros, structures, prototypes and 
  2.    global variables for LOADHIGH.C */
  3.  
  4. /* Macro to convert bytes to paragraphs */
  5. #define topara(x) (((x) + 0xf) >> 4)
  6.  
  7. /* Make sure the FP_SEG macro is a valid lvalue */
  8. #ifdef FP_SEG
  9. #  undef FP_SEG
  10. #endif
  11.  
  12. #define FP_SEG(x)  (*(((unsigned short *)&(x))+1))
  13.  
  14. /* typedefs for common DOS data types */
  15. typedef unsigned char BYTE;
  16. typedef unsigned short WORD;
  17. typedef unsigned long DWORD;
  18.  
  19. /* memory control block */
  20. struct MCB
  21. {
  22.    BYTE sig;
  23.    WORD owner;
  24.    WORD size;
  25.    BYTE res[3];
  26.    BYTE name[8];
  27. };
  28.  
  29. /* Prototypes for the assembler functions */
  30. WORD    DosAlloc(WORD paragraphs);              /* DOS func. 48h */
  31. WORD    DosSetStrategy(WORD strat);             /* DOS func. 5801h */
  32. int     DosSetUMBLink(int value);               /* DOS func. 5803h */
  33. int     DosResize(WORD block, WORD newSize);    /* DOS func. 4ah */
  34. void    DosFree(WORD block);                    /* DOS func. 49h */
  35. WORD    GetFirstMCB(void);
  36.  
  37. /* far memory version of memcmp() */
  38. int     farmemcmp(void far *s1, void far *s2, size_t nbytes);
  39.  
  40. /* These variables are used to save the DOS malloc strategy
  41.    and UMB link state, to restore them when the program terminates */
  42. WORD    old_link, old_strat;
  43. int     umbLink; /* This variable holds the current state of the UMB link */
  44.  
  45. char   *newcmdline;      /* New command line */
  46.  
  47. /* characters that delimit the file name */
  48. char   *filename_delimitors = " \t\r\n/;,+=<>|[]\"";
  49.  
  50. /* This array will contain the memory blocks that the new program can't use */
  51. int     allocatedBlocks = 0;
  52. WORD   *block;
  53.  
  54. char    *filename;
  55.  
  56. int     swShrink;       /* Flag: was the 'S' switch present? */
  57. int     swLoad;         /* Flag: was the 'L' switch present? */
  58. int     loadfix_flag;   /* Flag: are we processing LOADFIX or LOADHIGH? */
  59. int     upper_flag;     /* Flag: should the program be loaded high? */
  60.  
  61. /* UMB region info */
  62. int     umbRegions = 0; /* How many UMB regions are there? */
  63.  
  64. struct UMBREGION {
  65.   WORD start;      /* start of the region */
  66.   WORD end;        /* end of the region */
  67.   WORD minSize;    /* minimum free size, given by the L switch */
  68.   int  access;     /* does the program have access to this region? */
  69. } *umbRegion;
  70.  
  71.  
  72. /* functions... */
  73. void    loadhigh(int, char *[128], char *cmd);
  74. void    loadfix(int, char *[128], char *cmd);
  75. int     findUMBRegions(void);
  76. int     parseArgs(char *cmdline);
  77. void    lh_error(int errcode);
  78. int     lh_lf(char *c);
  79. int     loadhigh_prepare(void);
  80. int     loadfix_prepare(void);
  81. int     initialise(void);
  82. void    cleanup(void);
  83.  
  84. enum error_codes {
  85.   err_help = -1, OK, 
  86.   
  87.   /* These error codes are more or less DOS-compatible */
  88.   err_file_not_found = 2, err_mcb_chain = 7,
  89.   err_out_of_memory = 8, err_invalid_parms = 87
  90. };
  91.  
  92. /* error message strings */
  93. #define REGION_WARNING  "LOADHIGH: Illegal memory region %d - ignored\n"
  94. #define FILENOTFOUND    "file not found"
  95. #define OUTOFMEMORY     "out of memory"
  96. #define BADUSAGE        "invalid command line"
  97. #define BADMCBCHAIN     "MCB chain corrupt, or MS-DOS incompatible system"
  98.  
  99. /* usage strings */
  100. char    loadhigh_usage[] =
  101.   "LOADHIGH loads a program into the upper memory.\n\n"
  102.   "Usage: LOADHIGH [options] filename [arguments to <filename>]\n\n"
  103.   " /L:m[,n][;m[,n]]...  Specify which UMB regions the program can use\n"
  104.   " /S                   Shrink the regions to minimal size"
  105. ;
  106.  
  107. char    loadfix_usage[] =
  108.   "LOADFIX loads a program above the first 64 kb.\n\n"
  109.   "Usage: LOADFIX filename [arguments to <filename>]"
  110. ;
  111.  
  112.  
  113.